$(function () {
    var currentPage = 1;
    var pageSize = 5;
    var id=null
    var isdelete=null
    render()

    function render() {
        $.ajax({
            type: 'get',
            url: "/user/queryUser",
            data: {
                page: currentPage,
                pageSize: pageSize
            },
            success: function (info) {
               $('tbody').html(template('npm',info))
               setPage(info.total);
            //    console.log(info.total)
            }
        })
    }
$('tbody').on('click','.btn',function(){
  id=$(this).parent().parent().data('id')
//   console.log($(this).hasClass('btn-danger'))
 isdelete= $(this).hasClass('btn-danger')?0:1
//  console.log(isdelete)
})
  $('.dure').on('click',function(){
      $.ajax({
          type:'post',
          url:'/user/updateUser',
          data:{
              id:id,
              isDelete:isdelete
          },
          success:function(info){
           render(currentPage)
           $('.open').modal('hide')
          
          }
      })
  })

  function setPage(total) {
    $("#paginator").bootstrapPaginator({
        bootstrapMajorVersion: 3,//默认是2，如果是bootstrap3版本，这个参数必填
        currentPage: currentPage,//当前页
        totalPages: Math.ceil(total / pageSize),//总页数          
        onPageClicked: function (event, originalEvent, type, page) {
            //为按钮绑定点击事件 page:当前点击的按钮对应页码
            console.log(page);  
            currentPage = page;
            //请求对应页码的数据，重新渲染
            render();
        }
    });
}

})